home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / ObjectTcl-1.1 / OtclMethod.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-30  |  5.8 KB  |  177 lines

  1. #ifndef OTCL_METHOD_H
  2. #define OTCL_METHOD_H
  3.  
  4. /*  _ __ ___ _
  5.  * | |\ /  /| |  $Id: OtclMethod.H,v 1.6 1995/05/09 16:14:35 deans Exp $
  6.  * | | /  / | |  Copyright (C) 1995 IXI Limited.
  7.  * |_|/__/_\|_|  IXI Limited, Cambridge, England.
  8.  *
  9.  * Component   : OtclMethod.H
  10.  *
  11.  * Author      : Dean Sheehan (deans@x.co.uk)
  12.  *  
  13.  * Description : Header file for OtclMethod, and subclasses, that models
  14.  *               constructors, destructors, instance and class methods on
  15.  *               OtclClasses.
  16.  *
  17.  * License     :
  18.             Object Tcl License & Copyright
  19.             -----------------------------
  20.  
  21. IXI Object Tcl software, both binary and source (hereafter, Software) is copyrighted by IXI Limited (IXI), and ownership remains with IXI. 
  22.  
  23. IXI grants you (herafter, Licensee) a license to use the Software for academic, research and internal business purposes only, without a fee. Licensee may distribute the binary and source code (if required) to third parties provided that the copyright notice and this statement appears on all copies and that no charge is associated with such copies. 
  24.  
  25. Licensee may make derivative works. However, if Licensee distributes any derivative work based on or derived from the Software, then Licensee will (1) notify IXI regarding its distribution of the derivative work, and (2) clearly notify users that such derivative work is a modified version and not the original IXI Object Tcl distributed by IXI. IXI strongly recommends that Licensee provide IXI the right to incorporate such modifications into future releases of the Software under these license terms. 
  26.  
  27. Any Licensee wishing to make commercial use of the Software should contact IXI, to negotiate an appropriate license for such commercial use. Commercial use includes (1) integration of all or part of the source code into a product for sale or license by or on behalf of Licensee to third parties, or (2) distribution of the binary code or source code to third parties that need it to utilize a commercial product sold or licensed by or on behalf of Licensee. 
  28.  
  29. IXI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. IXI SHALL NOT BE LIABLE FOR ANY DAMAGES WHATSOEVER SUFFERED BY THE USERS OF THIS SOFTWARE. 
  30.  
  31. Copyright (C) 1995, IXI Limited 
  32.  
  33. By using or copying this Software, Licensee agrees to abide by the copyright law and all other applicable laws of England and the U.S., including, but not limited to, export control laws, and the terms of this license. IXI shall have the right to terminate this license immediately by written notice upon Licensee's breach of, or non-compliance with, any of its terms. Licensee may be held legally responsible for any copyright infringement that is caused or encouraged by Licensee's failure to abide by the terms of this license. 
  34.  
  35. Comments and questions are welcome and can be sent to
  36. otcl@x.co.uk 
  37.  
  38. For more information on copyright and licensing issues, contact: 
  39. Legal Department, IXI Limited, Vision Park, Cambridge CB4 4ZR,
  40. ENGLAND. 
  41.  
  42.  *
  43.  */
  44.  
  45. // Tcl Includes
  46. #include <tcl.h>
  47.  
  48. // Local Includes
  49. #include "OtclClass.H"
  50.  
  51. // Public Defines
  52. #define OTCL_CONSTRUCTOR_METHOD_NAME "constructor"
  53. #define OTCL_DESTRUCTOR_METHOD_NAME  "destructor"
  54.  
  55. // Forward Class Declarations
  56. class OtclPart;
  57. class OtclPartOtcl;
  58. class OtclFormalArg;
  59.  
  60. class OtclMethod
  61. {
  62. public:   // Public Enumerations
  63.  
  64.    enum Access {PUBLIC, PRIVATE};
  65.  
  66. public:   // Constructor & Destructor
  67.  
  68.    OtclMethod (char *name, Access, OtclClassOtcl *otclClass);
  69.  
  70.    virtual ~OtclMethod ();
  71.  
  72. public:   // Public Instance Methods
  73.  
  74.    virtual int setFormalArgs (Tcl_Interp *interp, char *formalArgs);
  75.  
  76.    int setBody (Tcl_Interp *interp, char *body);
  77.  
  78.    int hasBody (void);
  79.  
  80.    // Execute this method in the current interpreter call frame
  81.    // Assumes caller has set up object & class scope in frame
  82.    int execute (Tcl_Interp *, int argc, char *argv[]);
  83.  
  84.    int isAccessible (Tcl_Interp *);
  85.  
  86.    char *giveFirstFormalArgName (void);
  87.    char *giveNextFormalArgName (void);
  88.  
  89. protected: // Protected Instance Methods
  90.  
  91.    int bindActualToFormal (Tcl_Interp *, int argc, char *argv[]);
  92.  
  93.    int evaluateMethodBody (Tcl_Interp *);
  94.  
  95. private:  // Private Instance Methods
  96.  
  97.    int overlayFormalArgs (Tcl_Interp *, char *args);
  98.  
  99.    int argExists (char *name, OtclFormalArg *end);
  100.  
  101. protected:  // Protected Attributes
  102.  
  103.    char *name;
  104.  
  105.    OtclMethod::Access access;
  106.  
  107.    OtclClassOtcl *otclClass;
  108.  
  109.    char *body;
  110.  
  111. private:  // Private Instance Attributes
  112.  
  113.    // A list of OtclFormalArg objects
  114.    int formalArgsSpecified;
  115.    OtclFormalArg *formalArgHead;
  116.    OtclFormalArg *formalArgTail;
  117.    OtclFormalArg *currentFormalArg;
  118.  
  119. };
  120.  
  121. class OtclInstanceMethod : public OtclMethod
  122. {
  123. public:   // Constructor & Destructor
  124.  
  125.    OtclInstanceMethod (char *name, OtclMethod::Access,
  126.                        OtclClassOtcl *otclClass);
  127.  
  128.    virtual ~OtclInstanceMethod ();
  129.  
  130. public:   // Public Instance Methods
  131.  
  132. };
  133.  
  134. class OtclConstructorMethod : public OtclInstanceMethod
  135. {
  136. public:   // Constructor & Destructor
  137.  
  138.    OtclConstructorMethod (OtclClassOtcl *otclClass);
  139.  
  140.    virtual ~OtclConstructorMethod ();
  141.  
  142. public:   // Public Instance Methods
  143.  
  144.    int setParentConstructors (Tcl_Interp *, char *parentConstructors);
  145.  
  146.    int execute (Tcl_Interp *, int argc, char *argv[], OtclPartOtcl *part);
  147.  
  148. private:  // Private Instance Attributes
  149.  
  150.    char *parentConstructorArgs[MAX_SUPERCLASSES];
  151.  
  152. };
  153.  
  154. class OtclDestructorMethod : public OtclInstanceMethod
  155. {
  156. public:   // Constructor & Destructor
  157.  
  158.    OtclDestructorMethod (OtclClassOtcl *otclClass);
  159.  
  160.    virtual ~OtclDestructorMethod ();
  161.  
  162. public:   // Public Instance Methods
  163.  
  164.    int setFormalArgs (Tcl_Interp *, char *formalArgs);
  165. };
  166.  
  167. class OtclClassMethod : public OtclMethod
  168. {
  169. public:   // Constructor & Destructor
  170.  
  171.    OtclClassMethod (char *name, OtclMethod::Access, OtclClassOtcl *otclClass);
  172.  
  173.    virtual ~OtclClassMethod ();
  174. };
  175.  
  176. #endif // OTCL_METHOD_H
  177.